package com.freesky.biz.icbc.controller;

import com.freesky.biz.icbc.domain.TIntegralPartner;
import com.freesky.biz.icbc.domain.TIntegralPartnerRecord;
import com.freesky.biz.icbc.domain.TIntegralPartnerUser;
import com.freesky.biz.icbc.service.IIntegralPartnerService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 积分合伙人
 */
@RestController
@RequestMapping("/icbc/integralpartner")
public class IntegralPartnerController extends BaseController {

    @Autowired
    private IIntegralPartnerService integralPartnerService;

    /**
     * 金币领取记录列表
     */
    @PreAuthorize("@ss.hasPermi('icbc:integralpartner:list')")
    @GetMapping("/list")
    public TableDataInfo list(TIntegralPartner integralPartner) {
        startPage();
        List<TIntegralPartner> list = integralPartnerService.findList(integralPartner);
        return getDataTable(list);
    }

    @Log(title = "积分合伙人", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:integralpartner:export')")
    @GetMapping("/export")
    public AjaxResult export(TIntegralPartner integralPartner,
                             HttpServletResponse response) {
        return integralPartnerService.exportFile(integralPartner);
    }

    //导出记录
    @PreAuthorize("@ss.hasPermi('icbc:integralpartner:list')")
    @GetMapping("/listUser")
    public TableDataInfo listUser(TIntegralPartnerUser integralPartnerUser) {
        startPage();
        List<TIntegralPartnerUser> list = integralPartnerService.findUserList(integralPartnerUser);
        return getDataTable(list);
    }

    @Log(title = "积分合伙人", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:integralpartner:export')")
    @GetMapping("/exportUser")
    public AjaxResult exportUser(TIntegralPartnerUser integralPartnerUser,
                             HttpServletResponse response) {
        return integralPartnerService.exportUserFile(integralPartnerUser);
    }

    @PreAuthorize("@ss.hasPermi('icbc:integralpartner:list')")
    @GetMapping("/listRecord")
    public TableDataInfo listRecord(TIntegralPartnerRecord integralPartnerRecord) {
        startPage();
        List<TIntegralPartnerRecord> list = integralPartnerService.findRecordList(integralPartnerRecord);
        return getDataTable(list);
    }

    @Log(title = "积分合伙人", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:integralpartner:export')")
    @GetMapping("/exportRecord")
    public AjaxResult exportRecord(TIntegralPartnerRecord integralPartnerRecord,
                                 HttpServletResponse response) {
        return integralPartnerService.exportRecordFile(integralPartnerRecord);
    }
}
